<?php

/**
 * Cinnamon Statistics Engine AbstractPlugin class
 */
abstract class AbstractPlugin {
	/**
	 * The identifier of this Plugin
	 */
	protected $id;

	/**
	 * Default constructor
	 */
	public function __construct() {
		// Registers this plugin as an Event Listener
		Cinnamon::registry('events')->addListener($this);		
		
		// figure out the plugin identifier
		$this->id = preg_replace('/Plugin$/i', '', get_class($this));
		$this->id = strtolower($this->id);
	}
	
	/**
	 * Returns the identifier of this plugin
	 */
	public function getIdentifier() {
		return $this->id;
	}
	
	/**
	 * Enables this plugin
	 */
	public function enable() {
	}
	
	/**
	 * Disables this plugin
	 */
	public function disable() {
	}

	/**
	 * Returns the instance of the Filter with the specified id. This function is called only once per filter
	 *
	 * @param string filterId the id of the filter
	 */
	public function getFilterInstance($filterId) {
		throw new Exception('Filter '. $filterId .' not found for plugin'. $this->getIdentifier());
	}
	
	/**
	 * Parses the XML file of this plugin and returns its description
	 *
	 * @param object the description of this plugin
	 */
	public function parse() {
		return ( Cinnamon::getPlugin($this->getIdentifier()) );
	}
}

?>